import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

class MyReapintBoundary extends StatefulWidget {
  @override
  _MyReapintBoundaryState createState() => _MyReapintBoundaryState();

}

class _MyReapintBoundaryState extends State<MyReapintBoundary> {
  int counter = 0;
  @override
  Widget build(BuildContext context) {
    return RepaintBoundary(
        child: Container(
          color: Colors.lightGreen,
          child: Column(
            children: [
              Text('~~~${counter}'),
              ElevatedButton(
                onPressed: () {
                  setState(() {
                    counter++;
                  });
                },
                child: Text('点击修改 Repaint 的文案'),
                style: ButtonStyle(
                  elevation: MaterialStateProperty.all(0),
                  enableFeedback: false,
                  splashFactory: NoSplash.splashFactory,
                  //将按钮背景设置为透明
                  backgroundColor: MaterialStateProperty.all(
                      Colors.transparent),
                ),
              )
            ],
          ),
        )
    );
  }
}
